from django.contrib.auth.models import Permission, Group

import xadmin

from xadmin import views
from .models import VerifyCode,UserProfile

class UserAdmin(object):
    list_display = ['username', 'mobile', 'company_name','principal','date_joined']


xadmin.site.unregister(UserProfile)
xadmin.site.register(UserProfile, UserAdmin)

# from .models import Banner,UserProfile,EmailVerifyRecord

# 创建admin的管理类,这里不再是继承admin，而是继承object
class EmailVerifyRecordAdmin(object):
    list_display = ['code', 'email', 'send_type', 'send_time']
    # 配置搜索字段,不做时间搜索
    search_fields = ['code', 'email', 'send_type']
    # 配置筛选字段
    list_filter = ['code', 'email', 'send_type', 'send_time']

    # 创建banner的管理类


class BannerAdmin(object):
    list_display = ['title', 'image', 'url', 'index', 'add_time']
    search_fields = ['title', 'image', 'url', 'index']
    list_filter = ['title', 'image', 'url', 'index', 'add_time']
    pass


class BaseSetting(object):
    # 开启主题功能
    enable_themes = True
    use_bootswatch = True


# xadmin.site.register(EmailVerifyRecord, EmailVerifyRecordAdmin)
# 将model与admin管理器进行关联注册
# xadmin.site.register(Banner, BannerAdmin)
# 将全局配置管理与view绑定注册
xadmin.site.register(views.BaseAdminView, BaseSetting)


# 创建X admin的全局管理器并与view绑定。


# x admin 全局配置参数信息设置
class GlobalSettings(object):
    site_title = "ImageThinking"
    site_footer = "Copyright 2018,ImageThinking"
    # 收起菜单
    menu_style = "accordion"
    # 将头部与脚部信息进行注册:

class VerifyCodeAdmin(object):
    list_display = ['code', 'mobile', "add_time"]




xadmin.site.register(views.CommAdminView, GlobalSettings)
xadmin.site.register(VerifyCode, VerifyCodeAdmin)
xadmin.site.register(views.LoginView,
                     login_template="xadmin/views/xadmin_login.html"
                     )


